// 帖子模块接口
import httpInstance from './index'

/**
 * 获取用户用户发布的帖子
 * 
 * @param {Object} userId 用户 id
 * 
 */
export function getUserPostAPI(userId) {
	return httpInstance.get(`/posts/getPosts/${userId}`)
	// return baseURL.get(`/getPosts?data.authorId=${userId}`);
}

/**
 * 发布帖子接口
 * 
 * @param {Object} postData 帖子数据
 *
 */
export function createPostAPI(postData) {
	return httpInstance.post(`/posts/createPost`, postData, {
		headers: {
			"Content-Type": "multipart/form-data"
		}
	});
}

/**
 * 保存帖子草稿接口
 * @param {Object} postData 帖子数据
 */
export function saveDraftAPI(postData) {
	return httpInstance.post(`/posts/saveDraft`, postData, {
		headers: {
			"Content-Type": "multipart/form-data"
		}
	});
}

/**
 * 获取帖子详细信息接口
 * 
 * @param {Object} postId 帖子 id
 */
export function getPostFullInfoAPI(postId) {
	return httpInstance.get(`/posts/exclude/getPostFullInfo/${postId}`);
}

/**
 * 获取所有帖子
 */
export function getAllPosts(current = 1, size = 20) {
	return httpInstance.get(`/posts/exclude/getAllPosts`, {
		params: {
			current,
			size
		}
	});
}

/**
 * 根据分类 id 获取帖子
 * @param {Object} categoryId
 */
export function getPostsByCategoryId(categoryId, current = 1, size = 20) {
	return httpInstance.get(`/posts/exclude/getPostsByCategoryId/${categoryId}`, {
		params: {
			current,
			size
		}
	});
}